<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>Elisa3: motors.h File Reference</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">Elisa3
   
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.6.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('motors_8h.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">motors.h File Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>Motors module.  
<a href="#details">More...</a></p>
<div class="textblock"><code>#include &quot;<a class="el" href="variables_8h_source.html">variables.h</a>&quot;</code><br/>
<code>#include &lt;avr\io.h&gt;</code><br/>
<code>#include &lt;avr\interrupt.h&gt;</code><br/>
<code>#include &quot;<a class="el" href="behaviors_8h_source.html">behaviors.h</a>&quot;</code><br/>
<code>#include &quot;<a class="el" href="speed__control_8h_source.html">speed_control.h</a>&quot;</code><br/>
<code>#include &quot;<a class="el" href="utility_8h_source.html">utility.h</a>&quot;</code><br/>
<code>#include &quot;<a class="el" href="eeprom_i_o_8h_source.html">eepromIO.h</a>&quot;</code><br/>
</div>
<p><a href="motors_8h_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="func-members"></a>
Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="motors_8h.html#a984b662dbcf5b55b90fc02e2f866a206">initMotors</a> ()</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Configure the timer3 and timer4 registers to work at about 122 Hz.  <a href="#a984b662dbcf5b55b90fc02e2f866a206"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="motors_8h.html#a03a15e1a0e7b850c435667674478c096">handleMotorsWithSpeedController</a> ()</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Change the motors speed (pwm registers) accordingly to the obstacle avoidance (if enabled). In this function both the motors velocities measurements are also updated (even if not needed).  <a href="#a03a15e1a0e7b850c435667674478c096"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="motors_8h.html#afca6b6bae07c747c6c7d4980ae19159f">handleMotorsWithNoController</a> ()</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Change the motors speed (pwm registers) accordingly to the obstacle avoidance (if enabled) and speed controller. In this function both the motors velocities measurements are also updated.  <a href="#afca6b6bae07c747c6c7d4980ae19159f"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="motors_8h.html#ad5a48454a238e152a50a46054faef69e">setLeftSpeed</a> (signed char vel)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Set the desired speed for the left motor.  <a href="#ad5a48454a238e152a50a46054faef69e"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="motors_8h.html#ac2e0fa600855023342f960b0960f894f">setRightSpeed</a> (signed char vel)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Set the desired speed for the right motor.  <a href="#ac2e0fa600855023342f960b0960f894f"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="motors_8h.html#a845819f66f38cc796aa80b1b34bf1062">handleCalibration</a> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="motors_8h.html#a7dd331623224e5765907e557696e5307">updateOdomData</a> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="motors_8h.html#af32f2e285d132059238f06dc9e59526a">initCalibration</a> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">signed int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="motors_8h.html#a8614958c5393625712d698818e02631f">getInputFromSpeed</a> (signed int s, unsigned char mode)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">signed int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="motors_8h.html#af76a4c98fa3e4f08e2457f227bad9435">cast_speed</a> (signed int vel)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="motors_8h.html#a5d82c1900c839ae10b9b23252b405ee7">getLeftSpeedFromInput</a> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="motors_8h.html#ad6901423b66ff381666f170119035c36">getRightSpeedFromInput</a> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="motors_8h.html#a92320c5124f0356c4a1c4dd1227eb9ba">writeDefaultCalibration</a> ()</td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><p>Motors module. </p>
<dl class="author"><dt><b>Author:</b></dt><dd>Stefano Morgani &lt;<a href="mailto:stefano@gctronic.com">stefano@gctronic.com</a>&gt; </dd></dl>
<dl class="version"><dt><b>Version:</b></dt><dd>1.0 </dd></dl>
<dl class="date"><dt><b>Date:</b></dt><dd>01.02.12 </dd></dl>
<dl class="copyright"><dt><b>Copyright:</b></dt><dd>GNU GPL v3</dd></dl>
<p>The motors are handled with two timers: timer3 for right motor and timer4 for left motor. Two independent timers are needed because the timer will reset when the output compare register matches the timer value. The settings for the two timers are the same; the related pwm frequency is 122 Hz and the duty cycle define the motors speed. In order to measure the consumption and speed of the motors respectively in the active and passive phase of the pwm, two interrupts per timer are generated: one at the beginning of the cycle (timer overflow) and another one when when the output compare matches (beginning of passive phase). </p>
</div><hr/><h2>Function Documentation</h2>
<a class="anchor" id="af76a4c98fa3e4f08e2457f227bad9435"></a><!-- doxytag: member="motors.h::cast_speed" ref="af76a4c98fa3e4f08e2457f227bad9435" args="(signed int vel)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">signed int <a class="el" href="motors_8h.html#af76a4c98fa3e4f08e2457f227bad9435">cast_speed</a> </td>
          <td>(</td>
          <td class="paramtype">signed int&#160;</td>
          <td class="paramname"><em>vel</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

</div>
</div>
<a class="anchor" id="a8614958c5393625712d698818e02631f"></a><!-- doxytag: member="motors.h::getInputFromSpeed" ref="a8614958c5393625712d698818e02631f" args="(signed int s, unsigned char mode)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">signed int <a class="el" href="motors_8h.html#a8614958c5393625712d698818e02631f">getInputFromSpeed</a> </td>
          <td>(</td>
          <td class="paramtype">signed int&#160;</td>
          <td class="paramname"><em>s</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned char&#160;</td>
          <td class="paramname"><em>mode</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

</div>
</div>
<a class="anchor" id="a5d82c1900c839ae10b9b23252b405ee7"></a><!-- doxytag: member="motors.h::getLeftSpeedFromInput" ref="a5d82c1900c839ae10b9b23252b405ee7" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="motors_8h.html#a5d82c1900c839ae10b9b23252b405ee7">getLeftSpeedFromInput</a> </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

</div>
</div>
<a class="anchor" id="ad6901423b66ff381666f170119035c36"></a><!-- doxytag: member="motors.h::getRightSpeedFromInput" ref="ad6901423b66ff381666f170119035c36" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="motors_8h.html#ad6901423b66ff381666f170119035c36">getRightSpeedFromInput</a> </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

</div>
</div>
<a class="anchor" id="a845819f66f38cc796aa80b1b34bf1062"></a><!-- doxytag: member="motors.h::handleCalibration" ref="a845819f66f38cc796aa80b1b34bf1062" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="motors_8h.html#a845819f66f38cc796aa80b1b34bf1062">handleCalibration</a> </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

</div>
</div>
<a class="anchor" id="afca6b6bae07c747c6c7d4980ae19159f"></a><!-- doxytag: member="motors.h::handleMotorsWithNoController" ref="afca6b6bae07c747c6c7d4980ae19159f" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="motors_8h.html#afca6b6bae07c747c6c7d4980ae19159f">handleMotorsWithNoController</a> </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Change the motors speed (pwm registers) accordingly to the obstacle avoidance (if enabled) and speed controller. In this function both the motors velocities measurements are also updated. </p>
<dl class="return"><dt><b>Returns:</b></dt><dd>none </dd></dl>

</div>
</div>
<a class="anchor" id="a03a15e1a0e7b850c435667674478c096"></a><!-- doxytag: member="motors.h::handleMotorsWithSpeedController" ref="a03a15e1a0e7b850c435667674478c096" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="motors_8h.html#a03a15e1a0e7b850c435667674478c096">handleMotorsWithSpeedController</a> </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Change the motors speed (pwm registers) accordingly to the obstacle avoidance (if enabled). In this function both the motors velocities measurements are also updated (even if not needed). </p>
<dl class="return"><dt><b>Returns:</b></dt><dd>none </dd></dl>

</div>
</div>
<a class="anchor" id="af32f2e285d132059238f06dc9e59526a"></a><!-- doxytag: member="motors.h::initCalibration" ref="af32f2e285d132059238f06dc9e59526a" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="motors_8h.html#af32f2e285d132059238f06dc9e59526a">initCalibration</a> </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

</div>
</div>
<a class="anchor" id="a984b662dbcf5b55b90fc02e2f866a206"></a><!-- doxytag: member="motors.h::initMotors" ref="a984b662dbcf5b55b90fc02e2f866a206" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="motors_8h.html#a984b662dbcf5b55b90fc02e2f866a206">initMotors</a> </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Configure the timer3 and timer4 registers to work at about 122 Hz. </p>
<dl class="return"><dt><b>Returns:</b></dt><dd>none </dd></dl>

</div>
</div>
<a class="anchor" id="ad5a48454a238e152a50a46054faef69e"></a><!-- doxytag: member="motors.h::setLeftSpeed" ref="ad5a48454a238e152a50a46054faef69e" args="(signed char vel)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="motors_8h.html#ad5a48454a238e152a50a46054faef69e">setLeftSpeed</a> </td>
          <td>(</td>
          <td class="paramtype">signed char&#160;</td>
          <td class="paramname"><em>vel</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Set the desired speed for the left motor. </p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">vel</td><td>desired velocity to set (from -100 to 100) </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>none </dd></dl>

</div>
</div>
<a class="anchor" id="ac2e0fa600855023342f960b0960f894f"></a><!-- doxytag: member="motors.h::setRightSpeed" ref="ac2e0fa600855023342f960b0960f894f" args="(signed char vel)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="motors_8h.html#ac2e0fa600855023342f960b0960f894f">setRightSpeed</a> </td>
          <td>(</td>
          <td class="paramtype">signed char&#160;</td>
          <td class="paramname"><em>vel</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Set the desired speed for the right motor. </p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">vel</td><td>desired velocity to set (from -100 to 100) </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>none </dd></dl>

</div>
</div>
<a class="anchor" id="a7dd331623224e5765907e557696e5307"></a><!-- doxytag: member="motors.h::updateOdomData" ref="a7dd331623224e5765907e557696e5307" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="motors_8h.html#a7dd331623224e5765907e557696e5307">updateOdomData</a> </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

</div>
</div>
<a class="anchor" id="a92320c5124f0356c4a1c4dd1227eb9ba"></a><!-- doxytag: member="motors.h::writeDefaultCalibration" ref="a92320c5124f0356c4a1c4dd1227eb9ba" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="motors_8h.html#a92320c5124f0356c4a1c4dd1227eb9ba">writeDefaultCalibration</a> </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

</div>
</div>
</div><!-- contents -->
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Defines</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="motors_8h.html">motors.h</a>      </li>

    <li class="footer">Generated on Thu Dec 4 2014 08:30:50 for Elisa3 by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.6.1 </li>
   </ul>
 </div>


</body>
</html>
